package org.intellij.plugins.junit4;

/**
 * Dumb string utilites. We'd use jakarta commons lang, but we don't want to
 * cart it around.
 *
 * @author Justin Tomich
 */
public class StringUtil
{
    public static String deNull(String string)
    {
        if (string == null) return "";
        return string;
    }


    public static void notEmpty(String value, String fieldName)
    {
        if (isEmpty(value)) iae(fieldName + " cannot be empty");
    }

    /**
     * Test a String for emptiness: null or "" String.
     *
     * @param string String to test
     * @return return true if string is null or ""
     */
    public static boolean isEmpty(String string)
    {
        if (string == null) return true;
        return string.equals("");
    }


    private static void iae(String reason)
    {
        throw new IllegalArgumentException(reason);
    }
}

